<%@ page language="java" contentType="text/html; charset=GB18030"
    pageEncoding="GB18030"%>
<%@ page import="com.ibm.ba.demo.entity.*" %>
<%@ page import="java.util.List" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%! 
/**
 * Generate HTML table of recommended products.
 * 
 * @param .
 */
public String generateAllTable(List<Product> products)
{	
	String output = 
		"<table id=\"RECOMMENDS_TABLE\">"+
			"<thead>"+
				"<tr>"+
					"<th style=\"width:50px\">ID</th>"+
					"<th style=\"width:350px\">Name</th>"+
				"</tr>"+
			"</thead>"+
			"<tfoot>"+
			"</tfoot>"+
			"<tbody>";

	for ( int i = 0 ; i < products.size() ; ++i ) {
		output += "<tr>";
		output += 		"<td>";
		output += 			String.valueOf(products.get(i).getProductId());
		output +=		"</td>";		
		output += 		"<td>";
		output += 			products.get(i).getProductName();
		output +=		"</td>";
		output += "</tr>";
	}
	
	output +=
			"</tbody>"+
		"</table>";
	return output;
}

%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">

	<style type="text/css">
		<!--
		body {
			margin-left: 0px;
			margin-top: 0px;
			margin-right: 0px;
			margin-bottom: 0px;
		}
		-->
		table {
				border-collapse:collapse;
				background:#EFF4FB url(/resources/images/teaser.gif) repeat-x;
				border-left:1px solid #686868;
				border-right:1px solid #686868;
				font:0.8em/145% 'Trebuchet MS',helvetica,arial,verdana;
				color: #333;
		}
		td, th {
				padding:5px;
		}

		caption {
				padding: 0 0 .5em 0;
				text-align: left;
				font-size: 1.4em;
				font-weight: bold;
				text-transform: uppercase;
				color: #333;
				background: transparent;
		}

		/* =links
		----------------------------------------------- */

		table a {
				color:#950000;
				text-decoration:none;
		}

		table a:link {}
		
		table a:visited {
				font-weight:normal;
				color:#666;
				text-decoration: line-through;
		}
		
		table a:hover {
				border-bottom: 1px dashed #bbb;
		}

		/* =head =foot
		----------------------------------------------- */
		
		thead th, tfoot th, tfoot td {
				background:#333 url(/resources/images/llsh.gif) repeat-x;
				color:#fff;
				text-align: left
		}

		tfoot td {
				text-align:right
		}

		/* =body
		----------------------------------------------- */
		
		tbody th, tbody td {
				border-bottom: dotted 1px #333;
		}
		
		tbody th {
				white-space: nowrap;
		}
		
		tbody th a {
				color:#333;
		}
		
		.odd {}
		
		tbody tr:hover {
				background:#fafafa
		}

	</style>

</head>
<body>
	<%
		// Get recommended list
		List<Product> result = (List<Product>) request.getAttribute("allProducts");
		if ( result == null )
			out.print("No data as all product list.");
		else
			out.print(generateAllTable(result));
	%>
</body>
</html>